# -*- coding: utf-8 -*-
# standard
import os
import sys

# third

# local
_P_PATH =  os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
if _P_PATH not in sys.path:
    sys.path.append(_P_PATH)
from models import *


"""
@Title:   
@File: 验证时间监听是否依赖属性修改.py
@Author: walle 2025年01日14日 14时12分40秒
@Version: 1.0.0
@Desc: 
"""


def test1():
    """
    使用属性修改的方法会触发监听事件
    你可以使用在 sensor_alert_listener 函数上打断点的方法验证
    """
    db_session = new_db_session()
    one = db_session.get(InFluxDBAlertOrm, 463)
    if one.status == 1:
        new_status = 0
    else:
        new_status = 1
    one.status = new_status
    db_session.commit()
    db_session.close()


def test2():
    """
    使用update修改的方法会不触发监听事件
    你可以使用在 sensor_alert_listener 函数上打断点的方法验证
    """
    db_session = new_db_session()
    one = db_session.get(InFluxDBAlertOrm, 463)
    if one.status == 1:
        new_status = 0
    else:
        new_status = 1
    s = update(InFluxDBAlertOrm).where(InFluxDBAlertOrm.id == 463).values(status=new_status)
    db_session.execute(s)
    db_session.commit()
    db_session.close()





if __name__ == '__main__':
    test1()
    pass